<script setup>
	import userApi from '@/apis/user'
	import {onLoad} from '@dcloudio/uni-app'
	import {ref} from 'vue'
	
	// 定义车辆信息
	const truckInfo = ref({})
	
	onLoad(()=>{
		getTruckInfo()
	})
	
	// 获取车辆信息
	const getTruckInfo = async ()=>{
		const {code,data} = await userApi.truck()
		if(code!==200) return uni.utils.toast('获取车辆数据失败')
		truckInfo.value = data
		console.log(data);
	}
	
</script>

<template>
  <view class="page-container">
    <swiper class="truck-pictures" indicator-active-color="#fff" circular indicator-dots>
      <swiper-item v-for="(item,index) in truckInfo.pictureList" :key="index">
        <image class="picture" mode="aspectFill" :src="item.url"></image>
      </swiper-item>
    </swiper>
    <view class="truck-meta">
      <uni-list :border="false">
        <uni-list-item :border="false" title="车辆编号" :rightText="truckInfo.id" />
        <uni-list-item :border="false" title="车辆号牌" :rightText="truckInfo.licensePlate" />
        <uni-list-item :border="false" title="车型" :rightText="truckInfo.truckType" />
        <uni-list-item :border="false" title="所属机构" :rightText="truckInfo.currentOrganName" />
        <uni-list-item :border="false" title="载重" :rightText="truckInfo.allowableLoad" />
      </uni-list>
    </view>
  </view>
</template>

<style lang="scss" scoped>
  @import './index.scss';
</style>